using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class UI_RhythmNode_Item : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler,IPointerClickHandler
{
    [SerializeField]
    private Image _node_Image;
    private Image node_Image
    {
        get
        {
            if (_node_Image != null)
            {
                _node_Image = this.GetComponent<Image>();
            }
            return _node_Image;
        }
    }
    public bool isSelected
    {
        get
        {
            return selected_Image.gameObject.activeSelf;
        }
        set
        {
            selected_Image.gameObject.SetActive(value);
        }
    }
    [SerializeField]
    private Image selected_Image;

    public System.Action<bool> swtichAction;

    public void Switch(bool isSwitch)
    {
        isSelected = isSwitch;
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        Color color = Color.green;
        color.a = 0.1f;
        node_Image.color = color;
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        Color color = Color.gray;
        color.a = 0.1f;
        node_Image.color = color;
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        Switch(!isSelected);
         swtichAction?.Invoke(isSelected);
    }
}
